/**
 * @file esp01s.h
 * @brief This is the header file for esp01s.c, which is the porting file for the AT command
 * module.
 * @version 1.0
 */

#ifndef _ESP01S_H
#define _ESP01S_H
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>      // 添加 isdigit() 所需的头文件
#include "t_at.h"
#ifdef __cplusplus
extern "C" {
#endif

#define ESP_FALSE 0
#define ESP_TRUE 1

/**
 * @brief Enumeration representing the possible states of the esp01s device.
 */
typedef enum {
    esp_online = 1,      /**< The device is online. */
    esp_power_on,        /**< The device is powered on. */
    esp_power_down,      /**< The device is powered down. */
} esp_dev_state;
typedef enum {
    esp_error = -1,
    esp_powr_open_ok,
    esp_powr_open_fail,
    esp_init_ok,
    esp_send_ok,
    esp_send_fail,
}esp_error_t;

typedef struct {
  char wifi_name[80];//WIFI名称
  char wifi_pass[30];//WIFI密码   
} espc_net_info;//要加入哪一个WIFI

//多主题订阅
typedef struct {
 char subtopic[80];         
} esp_mqtt_mux_subtopic;
//多主题发布
typedef struct {
 char pubtopic[80];         
} esp_mqtt_mux_pubtopic;

//最大支持3个主体订阅
typedef struct  {
    uint8_t esp01s_mqtt_id;//MQtt客户端ID号
    uint8_t ssl:1;    //是否启用加密连接 0:不启用 1:启用
    uint8_t topic_mux:1;  //是否启用多主题订阅 0:不启用 1:启用
    uint8_t topic_mux_num; //多主题订阅数量 1-3
    char txt_name[50];   //name
    char client_id[80];  // client_id
    char user_name[80];  // user_name
    char pass_word[80];  // pass_word
    char host[80];       // host
    int port;            // port
    esp_mqtt_mux_subtopic SubTopic[3]; // 订阅主题
    esp_mqtt_mux_pubtopic PubTopic[3]; // 发布主题
    int Qos;  // qos
} esp_mqttc_cfg;

typedef struct  {
    espc_net_info esp_net_info_t;
    esp_dev_state esp_status;
    esp_mqttc_cfg  smqtt[4];//设计4个mqttClient 最大支持5个
    uint8_t esp_mqttc_num;  //MQtt客户端ID号客户端数量
} esp_cfg_t;

extern esp_cfg_t esp_cfg;

extern t_at_t *ESP01s;

esp_error_t esp01s_cfg_t(esp_cfg_t *esp_cfg_t);


#ifdef __cplusplus
}
#endif
#endif

/*_ESP01S_H*/